package cn.itsource.ymcc.openfeign.factory;

import cn.itsource.ymcc.openfeign.CourseOpenfeign;
import cn.itsource.ymcc.result.JsonResult;
import cn.itsource.ymcc.vo.CourseUserLearnVo;
import feign.hystrix.FallbackFactory;
import org.springframework.stereotype.Component;

@Component
public class CourseOpenfeignFallbackFactory implements FallbackFactory<CourseOpenfeign> {
    @Override
    public CourseOpenfeign create(Throwable throwable) {
        return new CourseOpenfeign() {
            @Override
            public JsonResult get(Long id) {
                throwable.printStackTrace();//写了这个可以在控制台里面看
                return JsonResult.error(throwable.getMessage());
            }

            @Override
            public JsonResult getUserLearnInfo(CourseUserLearnVo courseUserLearnVo) {
                throwable.printStackTrace();//写了这个可以在控制台里面看
                return JsonResult.error(throwable.getMessage());
            }
        };
    }
}
